package com.fish.yssb.ui.page.activity.other;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.AbsoluteLayout;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.fish.yssb.R;
import com.fish.yssb.db.RealmDb;
import com.fish.yssb.db.bean.UserInfoTable;
import com.fish.yssb.ui.page.activity.base.BaseActivity;
import com.fish.yssb.ui.page.widget.CustomDialog;
import com.jaeger.library.StatusBarUtil;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;

import io.realm.RealmResults;


/**
 * A login screen that offers login via email/password.
 */
public class ShowTextActivity extends BaseActivity implements OnClickListener {
    private static final String TAG = ShowTextActivity.class.getSimpleName();

    LinearLayout tv_back;
    EditText et_username;
    EditText et_password;
    TextView et_usertype;
    TextView  tv_txt,tv_toptitle;

    private  static String mTitle="";
    private static String filePath="";

    public static void start(Context context,String title,String filepath) {
        mTitle = title;
        filePath = filepath;
        Intent intent = new Intent(context, ShowTextActivity.class);
        context.startActivity(intent);
    }

    @Override
    protected void onResume() {
        super.onResume();
//        PreventKeyboardBlockUtil.getInstance(this).setBtnView(et_password).register();
    }

    @Override
    protected void onPause() {
        super.onPause();
//        PreventKeyboardBlockUtil.getInstance(this).unRegister();
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        StatusBarUtil.setTransparent(this);
        StatusBarUtil.setLightMode(this);
        setContentView(R.layout.activity_show_text);

        initview();
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                showInfo();
            }
        });

    }


    //初始化视图
    private void initview() {
        //登录层、下拉层、其它登录方式层
        tv_back = (LinearLayout)findViewById(R.id.tv_back);
        tv_back.setOnClickListener(this);
        tv_toptitle =(TextView)findViewById(R.id.tv_toptitle);
        tv_toptitle.setText(mTitle);
        tv_txt = (TextView) findViewById(R.id.tv_txt);


    }
    private void showInfo() {
        File file = new File(filePath);
        String str = null;
        try {
            InputStream is = new FileInputStream(file);
            InputStreamReader input = new InputStreamReader(is, "UTF-8");
            BufferedReader reader = new BufferedReader(input);
            while ((str = reader.readLine()) != null) {
                tv_txt.append(str);
                tv_txt.append("\n");
            }

        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    @Override
    public void onClick(View view) {


        switch (view.getId()) {

            case R.id.tv_back:
                finish();
                break;

            default:
                break;
        }


    }


}

